home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWExcLib / Include / FWExcRun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  3.9 KB  |  122 lines  |  [TEXT/MPS ]

  1. #ifndef FWEXCRUN_H
  2. #define FWEXCRUN_H
  3. //========================================================================================
  4. //
  5. //    File:                FWExcRun.h
  6. //    Release Version:    $ 1.0d1 $
  7. //
  8. //    Creation Date:        3/28/94
  9. //
  10. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //========================================================================================
  13.  
  14. #ifndef   FWEXCEPT_H
  15. #include "FWExcept.h"
  16. #endif
  17.  
  18. #ifndef   FWDELSTA_H
  19. #include "FWDelSta.h"
  20. #endif
  21.  
  22. #ifndef   FWEXCTAS_H
  23. #include "FWExcTas.h"
  24. #endif
  25.  
  26. #ifdef FW_DEBUG
  27. #include <stdio.h>
  28. #endif
  29.  
  30. class _FW_CTryBlockContext;
  31. class _FW_CPrivNewHelper;
  32. class _FW_CAutoDestructObject;
  33.  
  34. //========================================================================================
  35. //    Functions for "unexpected" and "terminate"
  36. //
  37. //        See ARM, Section 15.6
  38. //========================================================================================
  39.  
  40. extern void terminate();
  41. extern void unexpected();
  42.  
  43. extern PFV set_terminate(PFV);
  44. extern PFV set_unexpected(PFV);
  45.  
  46. //========================================================================================
  47. // CLASS _FW_CExceptionRuntime
  48. //========================================================================================
  49.  
  50. class _FW_CExceptionRuntime
  51. {
  52. public:
  53.     enum
  54.     {
  55.         kDefaultExceptionBufferSize = 128
  56.             // Exception buffer size in bytes.
  57.             // This limits size of largest exception object that may be thrown
  58.     };
  59.     
  60.     static void Initialize(FW_SPrivExceptionGlobals& globals);
  61.     static void Terminate();
  62.  
  63.     static void Throw(const _FW_CException & thrownException);
  64.     static void ThrowSame();
  65.     static void ThrowConstructor(_FW_CException & thrownException);
  66.     static void ThrowSameConstructor();
  67.     static void CaughtException(FW_SPrivExceptionGlobals& globals, _FW_CException * caughtException);
  68.     static void CaughtEverythingException(FW_SPrivExceptionGlobals& globals);
  69.     static void CaughtNoInstanceException(FW_SPrivExceptionGlobals& globals);
  70.     static void CaughtReferenceException(FW_SPrivExceptionGlobals& globals);
  71.     static void KeepThrowing(FW_SPrivExceptionGlobals& globals);
  72.     static void CatchCleanup(FW_SPrivExceptionGlobals& globals);
  73.     static void ResetExceptionBufferSize(size_t newSize);
  74.     static PFV SetTerminate(PFV);
  75.     static PFV SetUnexpected(PFV);
  76.     
  77.     static void EndConstructor(_FW_CAutoDestructObject *object, size_t size);
  78.     
  79. #ifdef FW_DEBUG
  80.     static    FW_ClassReference SetBreakOnThrow(FW_ClassReference breakExceptionKind = NULL);
  81.     static    FW_ClassReference GetBreakOnThrow();
  82. #endif
  83.  
  84. private:
  85.     static void DeleteObjectsInContextAndJump(FW_SPrivExceptionGlobals& globals, _FW_CTryBlockContext * FWTryBlo);
  86.     static void PrimitiveThrow(const _FW_CException & thrownException);
  87.     static void PrimitiveThrowSame();
  88.  
  89. };
  90.  
  91. //========================================================================================
  92. // CLASS _FW_CExceptionRuntime INLINE Functions
  93. //========================================================================================
  94.  
  95. #ifdef FW_DEBUG
  96. inline FW_ClassReference _FW_CExceptionRuntime::SetBreakOnThrow(FW_ClassReference breakExceptionKind)
  97. {
  98.     FW_ClassReference previous = FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
  99.     FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind = breakExceptionKind;
  100.     return previous;
  101. }
  102. #endif
  103.  
  104. #ifdef FW_DEBUG
  105. inline FW_ClassReference _FW_CExceptionRuntime::GetBreakOnThrow()
  106. {
  107.     return FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
  108. }
  109. #endif
  110.  
  111. //========================================================================================
  112. // CLASS _FW_CExceptionRuntime INLINE Functions (Platform-independent Versions)
  113. //========================================================================================
  114.  
  115. inline void _FW_CExceptionRuntime::CatchCleanup(FW_SPrivExceptionGlobals& globals)
  116. {
  117.     globals.gCaughtException = NULL;
  118.     globals.gThrownException = NULL;
  119. }
  120.  
  121. #endif
  122.